package com.jie.demo1.controller.indexController;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jie.demo1.Sservice.FileInformationTableService;
import com.jie.demo1.pojo.FileInformationTable;
import com.jie.demo1.pojo.QueryPage;
import com.jie.demo1.pojo.Result;

import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;
@CrossOrigin(origins = "http://localhost:5173/")
@RestController
@RequestMapping("/index")
public class indexController {

    @Autowired
    private FileInformationTableService fileInformationTableService;
    //默认查询所有数据，自定义分页查询。用于打开前端网页时自动查询数据
    @CrossOrigin(origins = "http://localhost:5173/")
    @PostMapping("/selectAllPage")
    public Result<Page<FileInformationTable>> selectAllPage(){

        QueryPage queryPage = new QueryPage();
        // 分页查询，创建一个分页器
        Page<FileInformationTable> fileInformationTablePage =
                new Page<>(queryPage.getPageNum(), queryPage.getPageSize());
        // 调用service层方法进行分页查询
        Page<FileInformationTable> page = fileInformationTableService.manualSelcetPage(fileInformationTablePage);
        return Result.ok(page);
    }

    //默认查询所有数据，自动分页查询。用于打开前端网页时自动查询数据
    @CrossOrigin(origins = "http://localhost:5173/")
    @PostMapping("/selectAllPage1")
    public Result<Page<FileInformationTable>> selectAllPage1(@RequestBody QueryPage queryPage){
        System.out.println("开始"+queryPage.getPageNum());
        // 分页查询，创建一个分页器
        Page<FileInformationTable> fileInformationTablePage =
       new Page<>(queryPage.getPageNum(), queryPage.getPageSize());
        // 调用service层方法进行分页查询
        System.out.println("开始"+fileInformationTablePage.getCurrent());
        Page<FileInformationTable> page = fileInformationTableService.page(fileInformationTablePage);
        return Result.ok(page);
    }


}
